package org.example.controller;

import org.example.model.common.dtos.ResponseResult;
import org.example.model.user.UserInfo;
import org.example.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户个人信息管理
 */
@CrossOrigin
@RestController
@RequestMapping("/user-info")
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    /**
     * 根据用户id获取用户个人信息
     * @return
     */
    @GetMapping("/user-info")
    public ResponseResult SelectUserInfoByUserId () {
        return ResponseResult.okResult(userInfoService.SelectUserInfoByUserId());
    }

    /**
     * 根据id修改用户个人信息
     * @param userInfo
     * @return
     */
    @PutMapping("/user-info")
    public ResponseResult UpdateUserInfoById (@RequestBody UserInfo userInfo) {
        return ResponseResult.okResult(userInfoService.UpdateUserInfoById(userInfo));
    }
}
